<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
    
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
     Yolin
  </title>
  <meta name="generator" content="hexo-theme-yilia-plus">
  
  <link rel="shortcut icon" href="/favicon.png" />
  
  
<link rel="stylesheet" href="/css/style.css">

  
<script src="/js/pace.min.js"></script>


  

  

<link rel="alternate" href="/atom.xml" title="Yolin" type="application/atom+xml">
<script src="/assets/js/DPlayer.min.js"></script></head>

</html>

<body>
  <div id="app">
    <main class="content">
      
<section class="cover">
    
  <div class="cover-frame">
    <div class="bg-box">
      <img src="/images/cover2.jpg" alt="image frame" />
    </div>
    <div class="cover-inner text-center text-white">
      <h1><a href="/">Yolin</a></h1>
      <div id="subtitle-box">
        
        <span id="subtitle"></span>
        
      </div>
      <div>
        
      </div>
    </div>
  </div>
  <div class="cover-learn-more">
    <a href="javascript:void(0)" class="anchor"><i class="ri-arrow-down-line"></i></a>
  </div>
</section>



<script src="https://cdn.jsdelivr.net/npm/typed.js@2.0.11/lib/typed.min.js"></script>

<div id="main">
  <section class="outer">
  <article class="articles">
    
    
    
    
    <article id="post-常见算法总结" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/02/15/%E5%B8%B8%E8%A7%81%E7%AE%97%E6%B3%95%E6%80%BB%E7%BB%93/"
    >常见算法总结</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2021/02/15/%E5%B8%B8%E8%A7%81%E7%AE%97%E6%B3%95%E6%80%BB%E7%BB%93/" class="article-date">
  <time datetime="2021-02-15T13:45:02.000Z" itemprop="datePublished">2021-02-15</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E7%AE%97%E6%B3%95/">算法</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <blockquote>
<h1 id="一、基础算法"><a href="#一、基础算法" class="headerlink" title="一、基础算法"></a>一、基础算法</h1></blockquote>
<h2 id="1-斐波那锲数列"><a href="#1-斐波那锲数列" class="headerlink" title="1. 斐波那锲数列"></a>1. 斐波那锲数列</h2><p><img src="https://yolin121.oss-cn-beijing.aliyuncs.com/blogimg/20210215195510.png" alt=""></p>
<h2 id="2-从尾到头打印链表"><a href="#2-从尾到头打印链表" class="headerlink" title="2. 从尾到头打印链表"></a>2. 从尾到头打印链表</h2><p>输入一个链表，按链表值从尾到头的顺序返回一个ArrayList。</p>
<p>思路：使用栈实现，先全部入栈，再依次出栈</p>
      
      <a class="article-more-link" href="/2021/02/15/%E5%B8%B8%E8%A7%81%E7%AE%97%E6%B3%95%E6%80%BB%E7%BB%93/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E7%AE%97%E6%B3%95/" rel="tag">算法</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-微信小程序《日常》" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/02/13/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F%E3%80%8A%E6%97%A5%E5%B8%B8%E3%80%8B/"
    >微信小程序《日常》</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2021/02/13/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F%E3%80%8A%E6%97%A5%E5%B8%B8%E3%80%8B/" class="article-date">
  <time datetime="2021-02-13T10:45:02.000Z" itemprop="datePublished">2021-02-13</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%B0%8F%E7%A8%8B%E5%BA%8F/">小程序</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h1 id="引言"><a href="#引言" class="headerlink" title="引言"></a>引言</h1><ol>
<li>优秀的人之所以优秀，是因为他们的生活已经规范化，他们养成了一个又一个好习惯，到了某个时间，习惯会推动他们做事，不需要靠意志力。正如小老鼠走迷宫的实验，经过上百次不断重复走迷宫的经历，老鼠的习惯回路就形成在大脑里面，大脑将其编入习惯系统里面，然后就可以刻意地记住应该怎么走。为了要构建某个习惯，我们必须刻意的去做这件事情，如果把它存在脑子里面就会增加负担，所以必须把它可视化，这样就比较容易能够记得住，比较容易能够标准化的去进行刻意练习 。       </li>
</ol>
<ol start="2">
<li>我们大部分的拖延、迷茫、焦虑都是因为没有目标引起的。因为没有目标，做事没有方向感，注意力不集中，很容易被其他事情吸引，比如计划好学习，抖音却刷的停不下来。目标要定制的合理，可以是预期的，潜意识里对目标产生渴望，驱动你去努力实现它。</li>
</ol>
<p><strong>本小程序专注于用户的习惯培养，帮助用户构建习惯，懂得时间管理，合理利用零碎时间，培养兴趣，为生活创造价值。</strong></p>
<div id="dplayer0" class="dplayer hexo-tag-dplayer-mark" style="margin-bottom: 20px;"></div><script>(function(){var player = new DPlayer({"container":document.getElementById("dplayer0"),"theme":"#FADFA3","video":{"url":"https://yolin-1300189713.cos.ap-beijing.myqcloud.com/bandicam%202020-06-11%2021-24-18-089.mp4","pic":"https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.jpg"},"danmaku":{"id":"9E2E3368B56CDBB4","api":"https://api.prprpr.me/dplayer/","token":"tokendemo"}});window.dplayers||(window.dplayers=[]);window.dplayers.push(player);})()</script>

<p>开源地址：</p>
<p><a href="https://gitee.com/yolin121/daily" target="_blank" rel="noopener">https://gitee.com/yolin121/daily</a></p>
      
      <a class="article-more-link" href="/2021/02/13/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F%E3%80%8A%E6%97%A5%E5%B8%B8%E3%80%8B/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F/" rel="tag">微信小程序</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E9%A1%B9%E7%9B%AE/" rel="tag">项目</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-MyBatis核心知识整理" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/02/10/MyBatis%E6%A0%B8%E5%BF%83%E7%9F%A5%E8%AF%86%E6%95%B4%E7%90%86/"
    >Mybatis核心知识整理</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2021/02/10/MyBatis%E6%A0%B8%E5%BF%83%E7%9F%A5%E8%AF%86%E6%95%B4%E7%90%86/" class="article-date">
  <time datetime="2021-02-10T10:45:02.000Z" itemprop="datePublished">2021-02-10</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/MyBatis/">MyBatis</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="MyBatis"><a href="#MyBatis" class="headerlink" title="MyBatis"></a>MyBatis</h2><blockquote>
<p>  MyBatis是一款优秀的持久层框架，它支持自定义SQL、存储过程以及高级映射，免除了几乎所有的jdbc代码以及设置参数和获取结果集的工作，它可以通过简单的xml或注解来配置java对象作为数据库中的记录。</p>
</blockquote>
<h2 id="MyBatis的编程步骤"><a href="#MyBatis的编程步骤" class="headerlink" title="MyBatis的编程步骤"></a>MyBatis的编程步骤</h2><ol>
<li>创建SqlSessionFactory</li>
<li>通过SqlSessionFactory创建SqlSession</li>
<li>通过SqlSession执行数据库操作</li>
<li>调用session.commit()提交事务</li>
<li>调用session.close()关闭对话</li>
</ol>
<h2 id="MyBatis工作原理"><a href="#MyBatis工作原理" class="headerlink" title="MyBatis工作原理"></a>MyBatis工作原理</h2><ol>
<li>读取MyBatis配置文件（mybatis-config.xml）.它配置了MyBatis的运行环境等信息，例如数据库连接信息</li>
<li>加载映射文件，即SQL映射文件，改文件配置了操作数据库的sql语句</li>
<li>构造会话工厂SQLSessionFactory</li>
<li>根据会话工厂创建会话对象sqlSession，该对象包含了执行sql语句的所有方法</li>
<li>Executor执行器，MyBatis底层定义了一个Executor接口来操作数据库，它根据sqlSession传递的参数动态地生成需要执行的sql语句</li>
<li>MappedStatement对象，用于对映射信息的封装用于存储要映射的sql语句的id，参数等</li>
<li>输入参数映射，输入参数类型可以是Map、List等集合类型，也可以是基本数据类型</li>
<li>输出结果映射。</li>
</ol>
      
      <a class="article-more-link" href="/2021/02/10/MyBatis%E6%A0%B8%E5%BF%83%E7%9F%A5%E8%AF%86%E6%95%B4%E7%90%86/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/MyBatis/" rel="tag">MyBatis</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-Redis事务及实现乐观锁" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/02/06/Redis%E4%BA%8B%E5%8A%A1%E5%8F%8A%E5%AE%9E%E7%8E%B0%E4%B9%90%E8%A7%82%E9%94%81/"
    >Redis事务及实现乐观锁</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2021/02/06/Redis%E4%BA%8B%E5%8A%A1%E5%8F%8A%E5%AE%9E%E7%8E%B0%E4%B9%90%E8%A7%82%E9%94%81/" class="article-date">
  <time datetime="2021-02-06T08:45:02.000Z" itemprop="datePublished">2021-02-06</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Redis/">Redis</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h1 id="事务"><a href="#事务" class="headerlink" title="事务"></a>事务</h1><ul>
<li><strong>事务是一个单独的隔离操作</strong>：事务中所有命令都会序列化并按照顺序执行，不会被其他客户端发送来的命令打断</li>
<li><strong>事务是一个原子操作</strong>：事务中的命令要么全被执行，要么全失败</li>
</ul>
<blockquote>
<p>  ① 原子性 ( <em>Atomic</em> )</p>
<ul>
<li><p>事务的操作作为整体执行，要么全部执行，要么全部失败</p>
<p>② 一致性 ( <em>Consistency</em> )</p>
</li>
<li><p>数据在执行前和执行后处于一致状态</p>
<p>③ 隔离性 ( <em>Isolation</em> )</p>
</li>
<li><p>多个事务之间是隔离的，互不影响</p>
<p>④ 持久性 ( <em>Durability</em> )</p>
</li>
<li><p>一旦事务提交了，会持久化写到数据库，对数据库的修改是永久性的</p>
</li>
</ul>
</blockquote>
<h1 id="Redis事务"><a href="#Redis事务" class="headerlink" title="Redis事务"></a>Redis事务</h1><h2 id="Redis事务本质"><a href="#Redis事务本质" class="headerlink" title="Redis事务本质"></a>Redis事务本质</h2><blockquote>
<p>一组命令的集合（multi、exec、watch等）！一个事务中的所有命令都会被序列化，在事务执行的过程中，会按照顺序执行。</p>
<p><strong>因Redis是单进程的，所以也理解为事务总是带有隔离性的，但事务没有隔离级别的概念</strong></p>
</blockquote>
      
      <a class="article-more-link" href="/2021/02/06/Redis%E4%BA%8B%E5%8A%A1%E5%8F%8A%E5%AE%9E%E7%8E%B0%E4%B9%90%E8%A7%82%E9%94%81/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Redis/" rel="tag">Redis</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E4%B9%90%E8%A7%82%E9%94%81/" rel="tag">乐观锁</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E4%BA%8B%E5%8A%A1/" rel="tag">事务</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-初始Redis" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/02/05/%E5%88%9D%E5%A7%8BRedis/"
    >初识Redis</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2021/02/05/%E5%88%9D%E5%A7%8BRedis/" class="article-date">
  <time datetime="2021-02-05T08:45:02.000Z" itemprop="datePublished">2021-02-05</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Redis/">Redis</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="什么是Redis？"><a href="#什么是Redis？" class="headerlink" title="什么是Redis？"></a>什么是Redis？</h2><p>Redis 是一个使用 C 语言写成的高性能非关系型数据库。它支持存储的多种数据 类型，包括<strong>string(字符串)、list(链表)、set(集合)、zset(sorted set –有序集合)和 hash（哈希类型）</strong>。Redis的数据都基于缓存的，所以很快，每秒可以处理超过 10万次读写操 作。为保证数据的安全不丢失，也可以实现数据写入磁盘中，而且Redis的操作是原子性（对数据的更改要么全部执行，要么全部不执行 ）的。</p>
<h2 id="优缺点"><a href="#优缺点" class="headerlink" title="优缺点"></a>优缺点</h2><ul>
<li>优点：<ul>
<li>读写性能优异，Redis能读的速度是11万次/s,写的速度是81000次/s</li>
<li>支持数据的持久化（AOF和RDB）</li>
<li>支持事务，redis所有操作都是原子性的</li>
<li>数据结构丰富</li>
</ul>
</li>
<li>缺点：<ul>
<li>数据库容量受到物理内存的限制</li>
<li>不具备恢复功能，最怕主机宕机</li>
</ul>
</li>
</ul>
<h2 id="Redis为什么这么快"><a href="#Redis为什么这么快" class="headerlink" title="Redis为什么这么快"></a>Redis为什么这么快</h2><ol>
<li>完全基于内存，速度非常快</li>
<li>采用单线程，避免了上下文切换所耗费的时间，也不会有各种锁问题的性能消耗</li>
<li>使用多路I/O复用模型，非阻塞IO</li>
<li>底层模型是Redis自己构建了VM机制</li>
</ol>
      
      <a class="article-more-link" href="/2021/02/05/%E5%88%9D%E5%A7%8BRedis/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Redis/" rel="tag">Redis</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-注解实现原理" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/01/31/%E6%B3%A8%E8%A7%A3%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86/"
    >注解实现原理</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2021/01/31/%E6%B3%A8%E8%A7%A3%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86/" class="article-date">
  <time datetime="2021-01-31T08:45:02.000Z" itemprop="datePublished">2021-01-31</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h1 id="一、前言"><a href="#一、前言" class="headerlink" title="一、前言"></a>一、前言</h1><p>关于注解这一块内容，我个人觉得比较模糊的一个原因就是，我知道如何去定义一个注解，如何使用它，至于为什么要这样用？底层原理的话就不太晓得了，更是在学了Spring框架后越发觉得原理很重要，为什么一个配置就可以自动将类进行装载，随用随取呢？</p>
<p>特此记录学习日志，以便查漏补缺。</p>
<h1 id="二、注解回顾"><a href="#二、注解回顾" class="headerlink" title="二、注解回顾"></a>二、注解回顾</h1><h2 id="注解的理解"><a href="#注解的理解" class="headerlink" title="注解的理解"></a>注解的理解</h2><p>其实注解和注释是很像的，注释是给人看的，注解是给程序看的</p>
<p>来看一段代码</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Repository</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Admin</span> <span class="keyword">extends</span> <span class="title">Entity</span> </span>&#123;</span><br><span class="line">    <span class="keyword">private</span> Integer id;</span><br><span class="line">    <span class="keyword">private</span> String account;</span><br><span class="line">    <span class="keyword">private</span> String password;</span><br><span class="line">    <span class="keyword">private</span> String name;</span><br><span class="line">    <span class="keyword">private</span> String remark;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
      
      <a class="article-more-link" href="/2021/01/31/%E6%B3%A8%E8%A7%A3%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Java%E5%9F%BA%E7%A1%80/" rel="tag">Java基础</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Spring/" rel="tag">Spring</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%8F%8D%E5%B0%84/" rel="tag">反射</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%B3%A8%E8%A7%A3/" rel="tag">注解</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-Java知识汇总（日常更新）" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/01/20/Java%E7%9F%A5%E8%AF%86%E6%B1%87%E6%80%BB%EF%BC%88%E6%97%A5%E5%B8%B8%E6%9B%B4%E6%96%B0%EF%BC%89/"
    >Java知识汇总（日常更新）</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2021/01/20/Java%E7%9F%A5%E8%AF%86%E6%B1%87%E6%80%BB%EF%BC%88%E6%97%A5%E5%B8%B8%E6%9B%B4%E6%96%B0%EF%BC%89/" class="article-date">
  <time datetime="2021-01-20T08:45:02.000Z" itemprop="datePublished">2021-01-20</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <blockquote>
<h1 id="Java基础"><a href="#Java基础" class="headerlink" title="Java基础"></a>Java基础</h1></blockquote>
<h2 id="面向对象"><a href="#面向对象" class="headerlink" title="面向对象"></a>面向对象</h2><h3 id="1-面向对象的优缺点"><a href="#1-面向对象的优缺点" class="headerlink" title="1. 面向对象的优缺点"></a>1. 面向对象的优缺点</h3><ul>
<li>优点：容易维护、复用、扩展。由于面向对象有封装、继承和多态三大特性，可以设计出低耦合的系统，使系统更加灵活、更加易于维护</li>
<li>缺点：性能比面向过程低</li>
</ul>
<h4 id="构造函数"><a href="#构造函数" class="headerlink" title="构造函数"></a>构造函数</h4><p>是一种特殊的方法，主要用来在创建对象时初始化对象，即为对象成员变量赋初始值，总与new运算符一起使用在创建对象的语句中。</p>
<h3 id="2-封装"><a href="#2-封装" class="headerlink" title="2. 封装"></a>2. 封装</h3><p>把一个对象的属性私有化，同时提供一些可以被外界访问的属性和方法，便于使用，提高复用性和安全性。</p>
<h3 id="3-继承"><a href="#3-继承" class="headerlink" title="3. 继承"></a>3. 继承</h3><p>使用已存在的类作为基础并建立新的类，新的类可以定义自己的属性和方法，也可以使用父类非private修饰的属性和方法。</p>
<h3 id="4-多态"><a href="#4-多态" class="headerlink" title="4. 多态"></a>4. 多态</h3><p>多态分为编译时多态和运行时多态，其中编译时多态主要指方法的重载，运行时多态指的是方法的重写。</p>
<p>多态的实现</p>
<p>Java实现多态有三个必要条件：</p>
<ul>
<li>继承：多态中必须存在继承关系</li>
<li>重写：子类对父类中某些方法进行重新定义，在调用这些方法时就会调用子类的方法</li>
<li>向上转型（父类引用指向子类对象）：多态中需要将子类的引用赋给父类对象，只有这样该引用才能够具备技能调用父类的方法和子类的方法。</li>
</ul>
      
      <a class="article-more-link" href="/2021/01/20/Java%E7%9F%A5%E8%AF%86%E6%B1%87%E6%80%BB%EF%BC%88%E6%97%A5%E5%B8%B8%E6%9B%B4%E6%96%B0%EF%BC%89/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Java%E5%9F%BA%E7%A1%80/" rel="tag">Java基础</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/MySQL/" rel="tag">MySQL</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E7%BD%91%E7%BB%9C/" rel="tag">网络</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E9%9B%86%E5%90%88/" rel="tag">集合</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-HashMap探究-1" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/01/16/HashMap%E6%8E%A2%E7%A9%B6-1/"
    >HashMap探究</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2021/01/16/HashMap%E6%8E%A2%E7%A9%B6-1/" class="article-date">
  <time datetime="2021-01-16T06:45:02.000Z" itemprop="datePublished">2021-01-16</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="HashMap实现原理"><a href="#HashMap实现原理" class="headerlink" title="HashMap实现原理"></a>HashMap实现原理</h2><p>HashMap是基于Hash算法实现的，是通过put(key,value)存储，get(key)来获取，当传入key时，会根据key 的HashCode方法计算Hash值，根据Hash值将value保存在bucket里，当计算的Hash值相同时称为Hash冲突，HashMap的做法是用链表和红黑树来存储Hash值相同的value，是当数组大于等于64，链表长度达到8时会转换为红黑树（泊松分布）</p>
<h2 id="用String作为key有什么好处？"><a href="#用String作为key有什么好处？" class="headerlink" title="用String作为key有什么好处？"></a>用String作为key有什么好处？</h2><p>HashMap是通过key的HashCode来确定value的存储位置，因为字符串是不可变的，所以在创建的时候，它的Hashcode被缓存下来，不需要计算，所以相比其它对象更快。</p>
<h2 id="Hash的概念"><a href="#Hash的概念" class="headerlink" title="Hash的概念"></a>Hash的概念</h2><p>Hash的基本概念就是把任意长度的输入通过一个hash算法之后，映射成固定长度的输出</p>
      
      <a class="article-more-link" href="/2021/01/16/HashMap%E6%8E%A2%E7%A9%B6-1/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/HashMap/" rel="tag">HashMap</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E9%9B%86%E5%90%88/" rel="tag">集合</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-JVM探究" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/01/10/JVM%E6%8E%A2%E7%A9%B6/"
    >JVM探究</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2021/01/10/JVM%E6%8E%A2%E7%A9%B6/" class="article-date">
  <time datetime="2021-01-10T08:45:02.000Z" itemprop="datePublished">2021-01-10</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="JVM内存结构"><a href="#JVM内存结构" class="headerlink" title="JVM内存结构"></a>JVM内存结构</h2><p><img src="https://yolin121.oss-cn-beijing.aliyuncs.com/blogimg/Snipaste_2021-01-09_17-35-32.jpg" alt=""></p>
<h2 id="JDK1-8为何用元空间取代永久代？"><a href="#JDK1-8为何用元空间取代永久代？" class="headerlink" title="JDK1.8为何用元空间取代永久代？"></a>JDK1.8为何用元空间取代永久代？</h2><p>类及方法的信息等比较难确定其大小，因此对于永久代大小指定比较困难，太小容易出现永久代溢出，太大容易出现老年代溢出。</p>
<p>而且永久代为GC带来不必要的复杂度，且回收效率低。</p>
<h2 id="字符串常量、类文件常量池所在区域"><a href="#字符串常量、类文件常量池所在区域" class="headerlink" title="字符串常量、类文件常量池所在区域"></a>字符串常量、类文件常量池所在区域</h2><p>字符串常量在堆中分配，类文件常量池位于方法区，即元空间。</p>
      
      <a class="article-more-link" href="/2021/01/10/JVM%E6%8E%A2%E7%A9%B6/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/JVM/" rel="tag">JVM</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-多线程内容梳理" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/12/23/%E5%A4%9A%E7%BA%BF%E7%A8%8B%E5%86%85%E5%AE%B9%E6%A2%B3%E7%90%86/"
    >多线程内容梳理</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/12/23/%E5%A4%9A%E7%BA%BF%E7%A8%8B%E5%86%85%E5%AE%B9%E6%A2%B3%E7%90%86/" class="article-date">
  <time datetime="2020-12-23T15:45:02.000Z" itemprop="datePublished">2020-12-23</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <blockquote>
<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2></blockquote>
<p>本文针对多线程的内容进行梳理和总结，对之前的文章做以扩充，且持续更新</p>
<ul>
<li><a href="https://yolin121.gitee.io/2020/08/14/Java%E5%A4%9A%E7%BA%BF%E7%A8%8B-%E5%AE%9E%E7%8E%B0%E5%A4%9A%E7%BA%BF%E7%A8%8B/" target="_blank" rel="noopener">Java多线程(实现多线程)</a></li>
<li><a href="https://yolin121.gitee.io/2020/08/16/Java%E5%A4%9A%E7%BA%BF%E7%A8%8B-%E7%BA%BF%E7%A8%8B%E5%90%8C%E6%AD%A5/" target="_blank" rel="noopener">Java多线程(线程同步)</a></li>
</ul>
<h2 id="什么是进程和线程？区别是什么？"><a href="#什么是进程和线程？区别是什么？" class="headerlink" title="什么是进程和线程？区别是什么？"></a>什么是进程和线程？区别是什么？</h2><ul>
<li><strong>进程</strong>是系统进行资源分配和调用的基本单位，通俗的讲就是内存中运行的程序，每个进程都有自己独立的一块内存空间，一个进程可以有多个线程</li>
<li><strong>线程</strong>是进程中的一个控制单元，负责当前进程中程序的执行，一个进程至少有一个线程，多个线程可以共享数据。</li>
<li>区别：<ul>
<li>（内存分配）  同一进程的线程共享地址空间和资源，而进程之间的地址空间和资源是相互独立的。</li>
<li>（影响关系）    一个进程崩溃后，在保护模式下不会对其他进程产生影响，但一个线程崩溃整个程序会死掉，所以多进程比多进程健壮。</li>
</ul>
</li>
</ul>
      
      <a class="article-more-link" href="/2020/12/23/%E5%A4%9A%E7%BA%BF%E7%A8%8B%E5%86%85%E5%AE%B9%E6%A2%B3%E7%90%86/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%A4%9A%E7%BA%BF%E7%A8%8B/" rel="tag">多线程</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
  </article>
  

  
  <nav class="page-nav">
    
    <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="page-number" href="/page/3/">3</a><span class="space">&hellip;</span><a class="page-number" href="/page/10/">10</a><a class="extend next" rel="next" href="/page/2/">下一页</a>
  </nav>
  
</section>
</div>

      <footer class="footer">
  <div class="outer">
    <ul class="list-inline">
      <li>
        &copy;
        2020-2021
        张金
      </li>
      <li>
        
      </li>
    </ul>
    <ul class="list-inline">
      <li>
        
        
        <span>
  <i>PV:<span id="busuanzi_value_page_pv"></span></i>
  <i>UV:<span id="busuanzi_value_site_uv"></span></i>
</span>
        
      </li>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
        <img src="https://yolin121.oss-cn-beijing.aliyuncs.com/blogimg/beian.png">
        <a href="https://beian.miit.gov.cn"  style="color:#f72b07" target="_blank">陕ICP备20002449号</a>
      </li>

    </ul>
  </div>
</footer>
    <div class="to_top">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>
      </div>
    </main>
      <aside class="sidebar">
        <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="Yolin"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/playlist">歌单</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/video">视频</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/about">关于我</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友情链接</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
      </aside>
      <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
      
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/jquery.justifiedGallery.min.js"></script>


<script src="/js/lazyload.min.js"></script>


<script src="/js/busuanzi-2.3.pure.min.js"></script>


<script src="/js/share.js"></script>




<script>
  try {
    var typed = new Typed("#subtitle", {
    strings: ['肠断月明红豆蔻,','月似当时,','人似当时否？'],
    startDelay: 1500,
    typeSpeed: 200,
    loop: true,
    backSpeed: 40,
    showCursor: true
    });
  } catch (err) {
  }
  
</script>




<script>
  var ayerConfig = {
    mathjax: true
  }
</script>


<script src="/js/ayer.js"></script>


<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">


<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>



<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
  });

  MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for(i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>


<script type="text/javascript" src="https://js.users.51.la/20544303.js"></script>
  </div>
</body>

</html>